class Solution {
    public int uniquePaths(int m, int n) {
        int[][] d = new int[n+1][m+1];
        d[1][1] = 1;
        for(int i=1; i<=n; i++){
            for(int j=1; j<=m; j++)
                d[i][j] += (d[i-1][j]+d[i][j-1]);
        }
        return d[n][m];
    }
    
}